home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColButton.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  2.2 KB  |  123 lines

  1. import java.awt.Event;
  2. import java.awt.Graphics;
  3. import java.awt.Rectangle;
  4. import java.io.DataInputStream;
  5. import java.io.IOException;
  6.  
  7. final class ColButton extends ColObj {
  8.    private long urlIndex;
  9.    public int drawState = 1;
  10.    private int prevdrawState = 1;
  11.    protected ColGrph m_colGraphicObj;
  12.    boolean hasOverSound;
  13.    boolean hasDownSound;
  14.    private ColObjIntr upState;
  15.    private ColObjIntr dnState;
  16.    private ColObjIntr ovState;
  17.    private ColObjIntr overSoundObj;
  18.    private ColObjIntr downSoundObj;
  19.    public Rectangle m_bounds;
  20.  
  21.    public boolean EventProc(Event var1) {
  22.       boolean var2 = false;
  23.       int var3 = (int)(((float)var1.x + this.m_colGraphicObj.m_xOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  24.       int var4 = (int)(((float)var1.y + this.m_colGraphicObj.m_yOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  25.       if (var1.id == 502) {
  26.          if (this.m_bounds.inside(var3, var4)) {
  27.             this.drawState = 3;
  28.             var2 = false;
  29.          }
  30.  
  31.          this.m_colGraphicObj.m_appComp.buttonisDn = false;
  32.       }
  33.  
  34.       if (var1.id == 501 && this.m_bounds.inside(var3, var4)) {
  35.          this.drawState = 2;
  36.          this.m_colGraphicObj.m_appComp.buttonisDn = true;
  37.          var2 = true;
  38.       }
  39.  
  40.       if (var1.id == 503 || var1.id == 506) {
  41.          if (this.m_bounds.inside(var3, var4)) {
  42.             this.drawState = 3;
  43.             var2 = false;
  44.          } else {
  45.             this.drawState = 1;
  46.          }
  47.  
  48.          if (var1.id == 506) {
  49.             this.m_colGraphicObj.m_appComp.buttonisDn = true;
  50.             if (this.m_bounds.inside(var3, var4)) {
  51.                this.drawState = 2;
  52.                var2 = true;
  53.             }
  54.          }
  55.       }
  56.  
  57.       if (var1.id == 505) {
  58.          this.drawState = 1;
  59.          this.m_colGraphicObj.m_appComp.buttonisDn = false;
  60.       }
  61.  
  62.       if (this.prevdrawState != this.drawState) {
  63.          this.draw(this.m_colGraphicObj.m_appComp.getGraphics());
  64.       }
  65.  
  66.       return var2;
  67.    }
  68.  
  69.    public void draw(Graphics var1) {
  70.       if (this.drawState == 1) {
  71.          this.upState.draw(var1);
  72.       } else if (this.drawState == 2) {
  73.          if (this.hasDownSound && this.downSoundObj != null) {
  74.             ((ColSnd)this.downSoundObj).PlayClip();
  75.          }
  76.  
  77.          this.dnState.draw(var1);
  78.       } else {
  79.          if (this.hasOverSound && this.overSoundObj != null) {
  80.             ((ColSnd)this.overSoundObj).PlayClip();
  81.          }
  82.  
  83.          this.ovState.draw(var1);
  84.       }
  85.  
  86.       this.prevdrawState = this.drawState;
  87.    }
  88.  
  89.    public ColButton(DataInputStream var1, int var2, ColGrph var3, Graphics var4) throws IOException {
  90.       int var5 = var1.readInt();
  91.       this.m_colGraphicObj = var3;
  92.       this.m_bounds = new Rectangle();
  93.       this.m_bounds.y = (int)((float)var1.readInt() / 65536.0F);
  94.       this.m_bounds.x = (int)((float)var1.readInt() / 65536.0F);
  95.       this.m_bounds.height = (int)((float)var1.readInt() / 65536.0F);
  96.       this.m_bounds.width = (int)((float)var1.readInt() / 65536.0F);
  97.       this.hasOverSound = var1.readInt() == 1;
  98.       this.hasDownSound = var1.readInt() == 1;
  99.       this.upState = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  100.       ((ColImg)this.upState).useOffScreen = 1;
  101.       this.ovState = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  102.       ((ColImg)this.ovState).useOffScreen = 1;
  103.       this.dnState = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  104.       ((ColImg)this.dnState).useOffScreen = 1;
  105.       if (this.hasOverSound) {
  106.          this.overSoundObj = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  107.       }
  108.  
  109.       if (this.hasDownSound) {
  110.          this.downSoundObj = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  111.       }
  112.  
  113.    }
  114.  
  115.    public int getType() {
  116.       return 13;
  117.    }
  118.  
  119.    public Rectangle getBounds() {
  120.       return this.m_bounds;
  121.    }
  122. }
  123.